import re

import requests
import random
import execjs
import subprocess
import json
def create_16():
    str=''
    for i in range(4):
    # 生成一个范围在 [65536, 131071] 内的随机整数
        random_num = random.randint(65536, 131071)
        # 将随机整数转换为十六进制字符串
        hex_str = hex(random_num)[2:]
        # 去掉十六进制字符串的第一个字符
        result = hex_str[1:]
        str+=result
    return str
def first():
    headers = {
        'accept': 'application/json, text/javascript, */*; q=0.01',
        'accept-language': 'zh-CN,zh;q=0.9,en;q=0.8,en-GB;q=0.7,en-US;q=0.6',
        'priority': 'u=1, i',
        'referer': 'https://demos.geetest.com/slide-float.html',
        'sec-ch-ua': '"Not(A:Brand";v="99", "Microsoft Edge";v="133", "Chromium";v="133"',
        'sec-ch-ua-mobile': '?0',
        'sec-ch-ua-platform': '"Windows"',
        'sec-fetch-dest': 'empty',
        'sec-fetch-mode': 'cors',
        'sec-fetch-site': 'same-origin',
        'user-agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/133.0.0.0 Safari/537.36 Edg/133.0.0.0',
        'x-requested-with': 'XMLHttpRequest',
        # 'cookie': 'language=zh; Hm_lvt_25b04a5e7a64668b9b88e2711fb5f0c4=1740536179,1740541822; sensorsdata2015jssdkcross=%7B%22distinct_id%22%3A%222213454960%40qq.com%22%2C%22first_id%22%3A%22195400a69d9149c-013be8aebd7d39d-4c657b58-921600-195400a69da1448%22%2C%22props%22%3A%7B%22%24latest_traffic_source_type%22%3A%22%E8%87%AA%E7%84%B6%E6%90%9C%E7%B4%A2%E6%B5%81%E9%87%8F%22%2C%22%24latest_search_keyword%22%3A%22%E6%9C%AA%E5%8F%96%E5%88%B0%E5%80%BC%22%2C%22%24latest_referrer%22%3A%22https%3A%2F%2Fwww.baidu.com%2Flink%22%2C%22%24latest_landing_page%22%3A%22https%3A%2F%2Fm.geetest.com%2F%22%2C%22%24latest_referrer_host%22%3A%22%22%7D%2C%22%24device_id%22%3A%22195400a69d9149c-013be8aebd7d39d-4c657b58-921600-195400a69da1448%22%2C%22identities%22%3A%22eyIkaWRlbnRpdHlfY29va2llX2lkIjoiMTk1NDAwZDE5YjBjYjctMDhjYTM4MGJjYzk2ZGM4LTRjNjU3YjU4LTkyMTYwMC0xOTU0MDBkMTliMTE3ODUiLCIkaWRlbnRpdHlfbG9naW5faWQiOiIyMjEzNDU0OTYwQHFxLmNvbSJ9%22%2C%22history_login_id%22%3A%7B%22name%22%3A%22%24identity_login_id%22%2C%22value%22%3A%222213454960%40qq.com%22%7D%7D',
    }

    params = {
        't': '1740963588588',
    }

    response = requests.get('https://demos.geetest.com/gt/register-slide', params=params, headers=headers)
    return response.json()
def second(gt):

    headers = {
        'accept': '*/*',
        'accept-language': 'zh-CN,zh;q=0.9,en;q=0.8,en-GB;q=0.7,en-US;q=0.6',
        'referer': 'https://demos.geetest.com/',
        'sec-ch-ua': '"Not(A:Brand";v="99", "Microsoft Edge";v="133", "Chromium";v="133"',
        'sec-ch-ua-mobile': '?0',
        'sec-ch-ua-platform': '"Windows"',
        'sec-fetch-dest': 'script',
        'sec-fetch-mode': 'no-cors',
        'sec-fetch-site': 'same-site',
        'user-agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/133.0.0.0 Safari/537.36 Edg/133.0.0.0',
        # 'cookie': 'language=zh; Hm_lvt_25b04a5e7a64668b9b88e2711fb5f0c4=1740536179,1740541822; sensorsdata2015jssdkcross=%7B%22distinct_id%22%3A%222213454960%40qq.com%22%2C%22first_id%22%3A%22195400a69d9149c-013be8aebd7d39d-4c657b58-921600-195400a69da1448%22%2C%22props%22%3A%7B%22%24latest_traffic_source_type%22%3A%22%E8%87%AA%E7%84%B6%E6%90%9C%E7%B4%A2%E6%B5%81%E9%87%8F%22%2C%22%24latest_search_keyword%22%3A%22%E6%9C%AA%E5%8F%96%E5%88%B0%E5%80%BC%22%2C%22%24latest_referrer%22%3A%22https%3A%2F%2Fwww.baidu.com%2Flink%22%2C%22%24latest_landing_page%22%3A%22https%3A%2F%2Fm.geetest.com%2F%22%2C%22%24latest_referrer_host%22%3A%22%22%7D%2C%22%24device_id%22%3A%22195400a69d9149c-013be8aebd7d39d-4c657b58-921600-195400a69da1448%22%2C%22identities%22%3A%22eyIkaWRlbnRpdHlfY29va2llX2lkIjoiMTk1NDAwZDE5YjBjYjctMDhjYTM4MGJjYzk2ZGM4LTRjNjU3YjU4LTkyMTYwMC0xOTU0MDBkMTliMTE3ODUiLCIkaWRlbnRpdHlfbG9naW5faWQiOiIyMjEzNDU0OTYwQHFxLmNvbSJ9%22%2C%22history_login_id%22%3A%7B%22name%22%3A%22%24identity_login_id%22%2C%22value%22%3A%222213454960%40qq.com%22%7D%7D; GeeTestUser=b7db27c22a92bb79a6005fc495b81747',
    }

    params = {
        'gt': '019924a82c70bb123aae90d483087f94',
        'callback': 'geetest_1740963909523',
    }

    response = requests.get('https://apiv6.geetest.com/gettype.php', params=params, headers=headers)
    print(response.text)


def third(gt,challenge):
    headers = {
        'accept': '*/*',
        'accept-language': 'zh-CN,zh;q=0.9,en;q=0.8,en-GB;q=0.7,en-US;q=0.6',
        'referer': 'https://demos.geetest.com/',
        'sec-ch-ua': '"Not(A:Brand";v="99", "Microsoft Edge";v="133", "Chromium";v="133"',
        'sec-ch-ua-mobile': '?0',
        'sec-ch-ua-platform': '"Windows"',
        'sec-fetch-dest': 'script',
        'sec-fetch-mode': 'no-cors',
        'sec-fetch-site': 'same-site',
        'user-agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/133.0.0.0 Safari/537.36 Edg/133.0.0.0',
        # 'cookie': 'language=zh; Hm_lvt_25b04a5e7a64668b9b88e2711fb5f0c4=1740536179,1740541822; sensorsdata2015jssdkcross=%7B%22distinct_id%22%3A%222213454960%40qq.com%22%2C%22first_id%22%3A%22195400a69d9149c-013be8aebd7d39d-4c657b58-921600-195400a69da1448%22%2C%22props%22%3A%7B%22%24latest_traffic_source_type%22%3A%22%E8%87%AA%E7%84%B6%E6%90%9C%E7%B4%A2%E6%B5%81%E9%87%8F%22%2C%22%24latest_search_keyword%22%3A%22%E6%9C%AA%E5%8F%96%E5%88%B0%E5%80%BC%22%2C%22%24latest_referrer%22%3A%22https%3A%2F%2Fwww.baidu.com%2Flink%22%2C%22%24latest_landing_page%22%3A%22https%3A%2F%2Fm.geetest.com%2F%22%2C%22%24latest_referrer_host%22%3A%22%22%7D%2C%22%24device_id%22%3A%22195400a69d9149c-013be8aebd7d39d-4c657b58-921600-195400a69da1448%22%2C%22identities%22%3A%22eyIkaWRlbnRpdHlfY29va2llX2lkIjoiMTk1NDAwZDE5YjBjYjctMDhjYTM4MGJjYzk2ZGM4LTRjNjU3YjU4LTkyMTYwMC0xOTU0MDBkMTliMTE3ODUiLCIkaWRlbnRpdHlfbG9naW5faWQiOiIyMjEzNDU0OTYwQHFxLmNvbSJ9%22%2C%22history_login_id%22%3A%7B%22name%22%3A%22%24identity_login_id%22%2C%22value%22%3A%222213454960%40qq.com%22%7D%7D; GeeTestUser=b7db27c22a92bb79a6005fc495b81747',
    }
    params={
        "gt":"019924a82c70bb123aae90d483087f94",
        "challenge":"344e070f1ef792350b3ecd85c2209871",
        "lang:":"zh-cn",
        "pt":0,
        "client_type":"web",
        "w":'cXnhUcFYzA1A3o9VRt)cNqiEwaNJ6vhnKti0kR7XSIV7k8P18o3z4gigJHv8P91JfLnQheh8utuJjzak4aI(OtYfa9CB)6X3swltyJG4F1aB4LEgqFMG3u34SOut73Vlr7QD3IpUTZS5G11EZGhLj4vX0RGmUdq2uTrJsZLwK0VK03Y2zaGS5JE43AVKDAgtnnKfuzshtDszX9COKfHP904iLWIvO)4O5ti8p5TXLiYYvLUnAVn1oRO8jc3r2JlNxKm(qBL706fnS2GVv2BJ6mVbqw3LBP5)YLqTNMqdKW)ysnMSUxOouKZgg1DCNWEA36TpaMZKCPd0iziwv5MebZ44mvzbUV2cqBeo5d(4oGv9xOmIWRFnRnsUm3app6nF33zNTdHtdPINEKAw1ULHhSYTJw8KiFeXbhOAGxus(B4guIVnxrBJEAdP(w9krN5XryjHsJssbifSXyAnY(bnktH2GNLx1jdLlBhvK2STusYfvgBEZU5fQI5eQpTby2HwcXqKdaLnXEo1KTCYuDUJsEA11sshiUiLOUI6NlGjbuKXPFdmP1XkOtusHiPZEfKEwgmhQc74ankojujo868W26vLnRnG8mtJENU5wu)PYevY2W0rbfkXlvKUMTxq6Q4aTWrvlfK6c(eLzIleq9fVrqodeanwSRrYVywnbrfKaK9oDGWBGj2z8913rzi8oSLPEb9W)(eWXgu3aIHsSxehE)pPTvkJuVHB6GMuTmMi24FwP2DFOY9aFFVPRHfKH)Fqins5ePm3iwvjIq5m57BoR1nQ)uz8EpsdU2hYOK04yOXZCAqwGOTqL0guvJ8ZkGFTDVrKau(dD2uUpM0y7Sbk(ZO0sGQHjsbx0hsx2ZbEIcGA)4ogP93FzRvAiku9KZXUFm6ZkvENmof0hBllgdSkKknjU065l9UCuIDDNmt)eN(W4rtn6vXPipXfOvwE8WCGt4XkQa9JrTQBjhAUFvaTletXMLDNeU0a0pKgzyBtz9GWNqDRY6TApELyDRWhWk5z3CUgmsRZ88JnrR6)XCPfQgqj6O6nQHVDqh2AztJNkhNREydL8J4MVjXZm2t20MXGZNBsNKhG6SnpYUUNFNV57zse1UeEUNSBw4bLAk9GQ0HV8yuHCNUCQZ7a3yx4uYhoeSPtDJCYONdtwSQVC1eYg1dP8(VKpPyzILLHPHl07)HXTBjX5vWFjI5Rn)iIb)ykH7Y2sfwVzBdrSHgxrH4lmCnZPTdkIjEmNcjSNdH(ViE.13671ae09fa07e267cf8e24e6cc17e54bdf8c42ef8b566e00f201a238c8855a7a34602710264d6401e0351a2b1133e7598ffa73fdf4a5da01c8b320638dda6fcd70f244a3cbe76c926ecd913034d7557ee367dab1dfde540e1ecb0be75ab0ab600133010cc178df4360e035a0790c3ee6756d6195f818cafd76834ebd3a58dfb',
        "callback":"geetest_1740963906213"

    }
    response = requests.get(
        'https://apiv6.geetest.com/get.php',
        headers=headers,
        params=params
    )
    print(response.text)



def create_fist_w():
    t={
	"gt": "019924a82c70bb123aae90d483087f94",
	"challenge": "5356888674587974e4e24f3e1512b477",
	"offline": 'false',
	"new_captcha": 'true',
	"product": "float",
	"width": "300px",
	"https": 'true',
	"api_server": "apiv6.geetest.com",
	"protocol": "https://",
	"type": "fullpage",
	"static_servers": ["static.geetest.com/", "static.geevisit.com/"],
	"beeline": "/static/js/beeline.1.0.1.js",
	"voice": "/static/js/voice.1.2.4.js",
	"click": "/static/js/click.3.1.1.js",
	"fullpage": "/static/js/fullpage.9.1.9-cyhomb.js",
	"slide": "/static/js/slide.7.9.2.js",
	"geetest": "/static/js/geetest.6.0.9.js",
	"aspect_radio": {
		"slide": 103,
		"click": 128,
		"voice": 128,
		"beeline": 50
	},
	"cc": 8,
	"ww": 'true',
	"i": "-1!!-1!!-1!!-1!!-1!!-1!!-1!!-1!!-1!!-1!!-1!!-1!!-1!!-1!!-1!!-1!!-1!!-1!!-1!!-1!!-1!!-1!!-1!!-1!!-1!!-1!!-1!!-1!!-1!!-1!!-1!!-1!!-1!!-1!!-1!!-1!!-1!!-1!!-1!!-1!!-1!!-1!!-1!!-1!!-1!!-1!!-1!!-1!!-1!!-1!!-1!!-1!!-1!!-1!!-1!!-1!!-1!!-1!!-1!!-1!!-1!!-1!!-1!!-1!!-1!!-1!!-1!!-1!!-1!!-1!!-1!!-1!!-1!!-1"
}
    # t['gt']=gt
    # t['challenge']=challenge
    t=json.dumps(t,indent=None)
    t = re.sub(r"\s+", "", t)
    t=t.replace('"true"',"true")
    t=t.replace('"false"', "false")
    print(t)
    with open('1.js','r') as f:
        js_code=f.read
        process = subprocess.Popen(['node', '1',t], stdout=subprocess.PIPE)

        # 获取输出结果
        output, error = process.communicate()
        print(output)

if __name__ == '__main__':
    # l_16=create_16()
    # json_1=first()
    # print(json_1)
    # second(json_1["gt"])
    # third(json_1["gt"],json_1["challenge"])
    create_fist_w()